package com.example.peanutsubway.web;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.ShearCaptcha;
import com.example.peanutsubway.annotation.ResponseTypeAnnotation;
import com.example.peanutsubway.vo.UserInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author：zzt
 * @Version：1.0
 * @Date：2021/10/14-20:08
 * @Since:jdk1.8
 * @Description:
 */
@WebServlet("/captcha.do")
public class CaptchaServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100,4,4);
        lineCaptcha.write(resp.getOutputStream());
        String code = lineCaptcha.getCode();
        req.getSession().setAttribute("trueImgCode",code);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
